home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / progjour / 1991 / 02 / metaware / min.c < prev    next >
C/C++ Source or Header  |  1991-01-02  |  4KB  |  97 lines

  1. /*-------------------------------------------------------------*\
  2.  |   MIN.C   A Minimum Windows Program that displays a window. |
  3.  |           The window can be moved, sized, minimized and     |
  4.  |           maximized.  The WM_QUIT message is correctly      |
  5.  |           handled so that the program terminates properly.  |
  6. \*-------------------------------------------------------------*/
  7.  
  8. #define NOPROFILER
  9. #define NOKANJI
  10.  
  11. #include <Windows.H>
  12.  
  13. typedef long FAR PASCAL (*FARPROC2)();
  14.  
  15. extern int __acrtused;
  16.  
  17. /*-------------------------------------------------------------*\
  18.  |                    Function Prototypes.                     |
  19. \*-------------------------------------------------------------*/
  20. pragma Calling_convention (_CALLEE_POPS_STACK | _FAR_CALL | _SAVE_REGS | _WINDOWS);
  21.  
  22. far long MinWndProc (HWND, WORD, WORD, LONG);
  23.  
  24. pragma Calling_convention ();
  25.  
  26. pragma Calling_convention (_CALLEE_POPS_STACK | _SAVE_REGS);
  27. int WinMain (HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdLine, int cmdShow);
  28. pragma Calling_convention ();
  29.  
  30. /*-------------------------------------------------------------*\
  31.  |                 Main Function:  WinMain.                    |
  32. \*-------------------------------------------------------------*/
  33. int WinMain (HANDLE hInstance,   HANDLE hPrevInstance,
  34.              LPSTR  lpszCmdLine, int    cmdShow)
  35.     {
  36.     HWND     hwnd;
  37.     MSG      msg;
  38.     WNDCLASS wndclass;
  39.  
  40.     if (__acrtused);
  41.  
  42.     if (!hPrevInstance)
  43.         {
  44.         wndclass.lpszClassName = (LPSTR)"MIN:MAIN";
  45.         wndclass.hInstance     = hInstance;
  46.         wndclass.lpfnWndProc   = (FARPROC2)MinWndProc;
  47.         wndclass.hCursor       = LoadCursor (hInstance, (LPSTR)"hand");
  48.         wndclass.hIcon         = LoadIcon (hInstance,(LPSTR)"snapshot");
  49.         wndclass.lpszMenuName  = NULL;
  50.         wndclass.hbrBackground = COLOR_WINDOW+1;
  51.         wndclass.style         = NULL;
  52.         wndclass.cbClsExtra    = 0;
  53.         wndclass.cbWndExtra    = 0;
  54.  
  55.         RegisterClass( (LPWNDCLASS)&wndclass);
  56.         }
  57.  
  58.     hwnd = CreateWindow((LPSTR)"MIN:MAIN",    /* Class name.   */
  59.                         (LPSTR)"Minimum",     /* Title.        */
  60.                         WS_OVERLAPPEDWINDOW,  /* Style bits.   */
  61.                         CW_USEDEFAULT,        /* x - default.  */
  62.                         0,                    /* y - default.  */
  63.                         CW_USEDEFAULT,        /* cx - default. */
  64.                         0,                    /* cy - default. */
  65.                         NULL,                 /* No parent.    */
  66.                         NULL,                 /* Class menu.   */
  67.                         hInstance,            /* Creator.      */
  68.                         NULL);                /* Params.       */
  69.  
  70.     ShowWindow (hwnd, cmdShow);
  71.  
  72.     while (GetMessage((LPMSG)&msg, 0, 0, 0))
  73.         {
  74.         TranslateMessage((LPMSG)&msg); /*  Keyboard input.     */
  75.         DispatchMessage((LPMSG)&msg);
  76.         }
  77.     return 0;
  78.     }
  79.  
  80. /*-------------------------------------------------------------*\
  81.  |              Window Procedure:  MinWndProc.                 |
  82. \*-------------------------------------------------------------*/
  83. far long MinWndProc (HWND hwnd,   WORD wMsg,
  84.                      WORD wParam, LONG lParam)
  85.     {
  86.     switch (wMsg)
  87.         {
  88.         case WM_DESTROY:
  89.             PostQuitMessage(0);
  90.             break;
  91.  
  92.         default:
  93.             return(DefWindowProc(hwnd,wMsg,wParam,lParam));
  94.         }
  95.     return 0L;
  96.     }
  97.